package com.tong.calculator.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tong.calculator.common.CommonUtil;
import com.tong.calculator.common.PageQuery;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import com.tong.calculator.mapper.QuestionMapper;
import com.tong.calculator.pojo.DO.QuestionDO;
import com.tong.calculator.service.QuestionService;


@Service
public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, QuestionDO> implements QuestionService {

    @Override
    public IPage<QuestionDO> queryPage(PageQuery pageQuery) {
        Page<QuestionDO> page = new Page<>();
        page.setCurrent(pageQuery.getCurrent());
        page.setSize(pageQuery.getSize());
        QueryWrapper<QuestionDO> wrapper = new QueryWrapper<>();
        wrapper.like(!CommonUtil.isNullOrEmpty(pageQuery.getKey()), "name", pageQuery.getKey()).orderByAsc("order_by");

        return this.page(page, wrapper);
    }

}
